package com.chen;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;

public class DemoAtomicInt {
    public static void main(String[] args) {
//        AtomicInteger atomicInteger = new AtomicInteger(0);
//        System.out.println(atomicInteger.getAndIncrement());
//        System.out.println(atomicInteger.get());

        String s="hello world";

        HashMap<Character, Integer> map = new HashMap<>();

        char[] charArray = s.toCharArray();
        for (char c : charArray) {

            map.put(c, map.getOrDefault(c, 0) + 1);
        }

        Set<Map.Entry<Character, Integer>> entries = map.entrySet();
        for (Map.Entry<Character, Integer> entry : entries) {
            System.out.println(entry.getKey()+"---"+entry.getValue());
        }
    }
}
